import axios from 'axios'
import store from '../store/index.js'

export function request(config) {
  const instance = axios.create({
    baseURL: 'http://116.63.80.218:8082/wx/',
    timeout: 5000
  }) 

  instance.interceptors.request.use(function (config) {
    // 在发送请求之前做些什么
    if(store.state.userInfo) {
     config.headers['X-Litemall-Token'] = store.state.userInfo.token 
    }
    // console.log(config);
    return config;
  }, function (error) {
    // 对请求错误做些什么
    return Promise.reject(error);
  });

  return instance(config)
}
// console.log(store.state.userInfo.token);


